package com.czk.model.proxy.dynamincproxy.practice3;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Proxy;

/**
 * @Author:ChenZhangKun
 * @Date: 2022/8/25 14:09
 */
public class Test2 {
    public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Class<?> proxyClass = Proxy.getProxyClass(Test2.class.getClassLoader(), Worker.class);
        Constructor<?> constructor = proxyClass.getConstructor(InvocationHandler.class);
        InvocationHandler invocationHandler=new WorkHandler(new Fixer());
        Worker worker=(Worker)constructor.newInstance(invocationHandler);
        worker.work();
    }
}
